/**
 * 授权 API
 */
import {
	http
} from '../request/main.js'


/**
 * 加入购物车
 * 
 * @returns {Promise}
 */
export function addCart(goods_id, goods_name, goods_cover, goods_price, goods_data, goods_count) {
	return http.post('/order/addCart', {
		goods_id,
		goods_name,
		goods_cover,
		goods_price,
		goods_data,
		goods_count
	})
}

/**
 * 操作购物车
 * 
 * @returns {Promise}
 */
export function handleCart(cart_id, action) {
	return http.post('/order/handleCart', {
		cart_id,
		action
	})
}

/**
 * 清空购物车
 * 
 * @returns {Promise}
 */
export function emptyCart() {
	return http.post('/order/emptyCart')
}

/**
 * 购物车列表
 * 
 * @returns {Promise}
 */
export function getCartList() {
	return http.post('/order/getCartList')
}

/**
 * 预览订单
 * 
 * @returns {Promise}
 */
export function previewOrder(data) {
	return http.post('/order/previewOrder', data)
}

/**
 * 提交订单
 * 
 * @returns {Promise}
 */
export function submitOrder(data) {
	return http.post('/order/submitOrder', data)
}

/**
 * 立即支付
 * 
 * @returns {Promise}
 */
export function oncePay(order_no, channel) {
	return http.post('/order/oncePay', {
		order_no,
		channel
	})
}

/**
 * 获取订单详情
 * 
 * @returns {Promise}
 */
export function getOrderDetail(order_no) {
	return http.post('/order/getOrderDetail', {
		order_no
	})
}

/**
 * 获取订单列表
 * 
 * @returns {Promise}
 */
export function getOrderList(group, page, page_size) {
	return http.post('/order/getOrderList', {
		group,
		page,
		page_size
	})
}

/**
 * 取消订单
 * 
 * @returns {Promise}
 */
export function orderCancel(order_no) {
	return http.post('/order/orderCancel', {
		order_no
	})
}

/**
 * 删除订单
 * 
 * @returns {Promise}
 */
export function orderDelete(order_no) {
	return http.post('/order/orderDelete', {
		order_no
	})
}

/**
 * 申请退款
 * 
 * @returns {Promise}
 */
export function applyRefund(order_no, order_item_no, balance, amount, reason, comment) {
	return http.post('/order/applyRefund', {
		order_no,
		order_item_no,
		amount,
		reason,
		comment
	})
}

/**
 * 退款信息
 * 
 * @returns {Promise}
 */
export function refundInfo(refund_no) {
	return http.post('/order/refundInfo', {
		refund_no
	})
}

/**
 * 取消退款
 * 
 * @returns {Promise}
 */
export function refundCancel(refund_no) {
	return http.post('/order/refundCancel', {
		refund_no
	})
}

/**
 * 申请开票
 * 
 * @returns {Promise}
 */
export function applyInvoice(order_no, amount, data) {
	data.order_no = order_no
	data.amount = amount
	return http.post('/order/applyInvoice', data)
}

/**
 * 开票信息
 * 
 * @returns {Promise}
 */
export function invoiceInfo(invoice_no) {
	return http.post('/order/invoiceInfo', {
		invoice_no
	})
}

/**
 * 取消开票
 * 
 * @returns {Promise}
 */
export function invoiceCancel(invoice_no) {
	return http.post('/order/invoiceCancel', {
		invoice_no
	})
}

/**
 * 获取管理员订单列表
 * @param {Object} data - 请求参数
 */
export function getAdminOrderList(data) {
	return http.post('/order/adminList', data)
}

/**
 * 获取管理员订单详情
 * @param {number} id - 订单ID
 */
export function getAdminOrderDetail(id) {
	return http.post('/order/adminDetail', { id })
}
